﻿using Xunit;

namespace JoelAbrahamsson.BlogExtensions.Tests.BlogEntrySlugProviderTests
{
    public class ReplaceUnallowedCharactersTests
    {
        [Fact]
        public void ReplaceUnallowedCharacters_RemovesExclamationMarks()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "!";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);
        
            Assert.Equal(string.Empty, returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_ReplacesDashesWithHyphens()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "–";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal("-", returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_ReplacesSpacesWithHyphens()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = " ";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal("-", returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_ReplacesMultipleHyphensWithASingleOne()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "--";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal("-", returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_RemovesForwardSlashes()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "/";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal(string.Empty, returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_RemovesBackSlashes()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = @"\";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal(string.Empty, returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_RemovesQuotationMarks()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "\"";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal(string.Empty, returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_ReplacesCPoundWithLiteralCSharp()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "c#";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal("c-sharp", returnedSlug);
        }

        [Fact]
        public void ReplaceUnallowedCharacters_ReplacesAmpersandWithLiteralAnd()
        {
            BlogEntrySlugProvider provider = new BlogEntrySlugProvider(null);
            string input = "&";

            string returnedSlug = provider.ReplaceUnallowedCharacters(input);

            Assert.Equal("and", returnedSlug);
        }
    }
}
